package com.lijinjiang.proxy02;

/**
 * @ClassName UserServiceImpl
 * @Description TODO
 * @Author Li
 * @Date 2022/9/21 17:44
 * @ModifyDate 2022/9/21 17:44
 * @Version 1.0
 */
public class UserServiceImpl implements UserService {
    @Override
    public String login(String username, String password) {
        long startTime = System.currentTimeMillis();
        String res = "登录名或密码错误";
        if ("admin".equals(username) && "123456".equals(password)) {
            res = "登录成功";
        }
        try {
            Thread.sleep(1000);
        } catch (Exception e) {
            e.printStackTrace();
        }
        long endTime = System.currentTimeMillis();
        System.out.println("login方法耗时：" + (endTime - startTime) / 1000.0 + "s");
        return res;
    }

    @Override
    public void deleteUsers() {
        long startTime = System.currentTimeMillis();
        try {
            System.out.println("正在删除用户数据中...");
            Thread.sleep(2000);
        } catch (Exception e) {
            e.printStackTrace();
        }
        long endTime = System.currentTimeMillis();
        System.out.println("deleteUsers方法耗时：" + (endTime - startTime) / 1000.0 + "s");
    }

    @Override
    public String listUsers() {
        long startTime = System.currentTimeMillis();
        String res = "查询了10000条数据";
        try {
            Thread.sleep(3000);
        } catch (Exception e) {
            e.printStackTrace();
        }
        long endTime = System.currentTimeMillis();
        System.out.println("listUsers方法耗时：" + (endTime - startTime) / 1000.0 + "s");
        return res;
    }
}
